#ifndef __COMPONENT_FISH_OUT_OF_WATER_BEHAVIOR_H__
#define __COMPONENT_FISH_OUT_OF_WATER_BEHAVIOR_H__

#include "ComponentBehavior.hpp"
#include "Engine/MathUtils.hpp"
#include "Engine/Vector2.hpp"

#include "EasyMachine.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    struct ComponentCreature;
    struct ComponentPathfinding;

    class SubsystemTimeOfDay;

    struct ComponentFishOutOfWaterBehavior : public ComponentBehavior
    {
    protected:
        enum class MachineState
        {
            Inactive,           // 不活跃的
            Jump
        };

        class StateMachine : public EasyMachine<MachineState>
        {
        private:
            ComponentFishOutOfWaterBehavior * m_fishOutOfWater;
        public:
            StateMachine(ComponentFishOutOfWaterBehavior *fishOutOfWater);

            virtual void enter() override;
            virtual void update(float dt) override;
            virtual void leave() override;
        };

    protected:
        float m_isBend;
        float m_importanceLevel = 1.0f;
        float m_outOfWaterTime;

        Vector2 m_direction;

        StateMachine *m_stateMachine;

    public:
        ComponentCreature *componentCreature;
        SubsystemTimeOfDay *subsystemTimeOfDay;

        ComponentFishOutOfWaterBehavior() = default;
        ~ComponentFishOutOfWaterBehavior();

        virtual float getImportanceLevel() override;
        bool isOutOfWater();
        bool getIsBend();
        void setIsBend(bool isBend);


        virtual void update(float dt) override;
        virtual void load(const nlohmann::json &jsonData) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
    };
}

#endif
